package com.cy.pj.sys.web.controller;

import com.cy.pj.sys.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysAttendance;
import com.cy.pj.sys.service.SysAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/att/")
public class SysAttendanceController {
    @Autowired
    private SysAttendanceService sysAttendanceService;

    @PutMapping
    public JsonResult doUpdateAttendance(@RequestBody SysAttendance attendance){
        sysAttendanceService.updateAttendance(attendance);
        return new JsonResult("update ok");
    }
    @GetMapping("{id}")
    public JsonResult doFindById(@PathVariable Long id){
        return new JsonResult(sysAttendanceService.findById(id));
    }

    public JsonResult doFindAttendance(){
        return new JsonResult(sysAttendanceService.findAttendance());
    }

    @PostMapping
    public JsonResult doSaveAttendanc(@RequestBody SysAttendance attendance){
        sysAttendanceService.saveAttendance( attendance);
        return  new JsonResult("save ok");
    }
    @DeleteMapping("{id}")
    public JsonResult doDeleteById(@PathVariable  Integer id) {
        sysAttendanceService.deleteById(id);
        return new JsonResult("delete ok");
    }
    }

